/**
 * transform 变换 参数名
 */
export type typ_matrix_key =
  | 'scalX'
  | 'skew'
  | 'rotate'
  | 'scalY'
  | 'translateX'
  | 'translateY';

/**
 * 解析 transform matrix 信息 返回 给定 的 值
 * @param matrStr transform matrix 信息
 * @param type 指定返回 index
 */
export function spliteMatrix(matrStr: string, type: typ_matrix_key) {
  if (matrStr === 'none') {
    return false;
  }
  //matrix(1, 0, 0, 1, 0, -41.6)
  //matrix\((?<scalX>-?\d+(?:\.\d+)?),\s(?<skew>-?\d+(?:\.\d+)?),\s(?<rotate>-?\d+(?:\.\d+)?),\s(?<scalY>-?\d+(?:\.\d+)?),\s(?<translateX>-?\d+(?:\.\d+)?),\s(?<translateY>-?\d+(?:\.\d+)?)\)
  let regMatrixStr =
    /matrix\((?<scalX>-?\d+(?:\.\d+)?),\s(?<skew>-?\d+(?:\.\d+)?),\s(?<rotate>-?\d+(?:\.\d+)?),\s(?<scalY>-?\d+(?:\.\d+)?),\s(?<translateX>-?\d+(?:\.\d+)?),\s(?<translateY>-?\d+(?:\.\d+)?)\)/;
  let matchResult = matrStr.match(regMatrixStr)!;

  return matchResult.groups![type];
}
